package com.dykj.fireFighting.web.maintenance;

import com.dykj.fireFighting.api.fire.maintenanceplan.dto.RoutineMaintenanceDto;
import com.dykj.fireFighting.api.fire.maintenanceplan.entity.RoutineMaintenance;
import com.dykj.fireFighting.api.fire.maintenanceplan.service.IRoutineMaintenanceService;
import com.dykj.fireFighting.api.fire.maintenanceplan.vo.RoutineMaintenanceVo;
import com.dykj.fireFighting.common.core.annotation.AutoLog;
import com.dykj.fireFighting.common.core.api.CommonResult;
import com.dykj.fireFighting.common.core.vo.PageVo;
import com.dykj.fireFighting.web.base.shiro.ShiroUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 例行维保记录接口
 *
 * @Author zly
 * @Date 2021-07-28 16:30:03
 */
@Slf4j
@Api(value = "例行维保记录接口", tags = {"例行维保记录接口"})
@RestController
@RequestMapping("/routineMaintenance")
public class RoutineMaintenanceController {

    @DubboReference
    private IRoutineMaintenanceService routineMaintenanceService;


    /**
     * 例行维保记录列表
     *
     * @return
     */
    @AutoLog(value = "例行维保记录-分页列表查询")
    @ApiOperation(value = "例行维保记录分页列表", notes = "例行维保记录分页列表")
    @GetMapping("/list")
    public CommonResult<PageVo<RoutineMaintenanceVo>> treeGrid(RoutineMaintenanceDto routineMaintenanceDto) {

        routineMaintenanceDto.setSociologyDept(ShiroUtil.getUser().getEnterpriseId().toString());
        PageVo<RoutineMaintenanceVo> page = routineMaintenanceService.queryList(routineMaintenanceDto);
        return CommonResult.success(page);
    }

    /**
     * 获取例行维保记录信息
     */
    @AutoLog(value = "例行维保记录-获取例行维保记录信息")
    @ApiOperation(value = "获取例行维保记录信息", notes = "获取例行维保记录信息")
    @ApiImplicitParam(paramType = "path", name = "id", value = "主键ID", dataType = "String", required = true)
    @GetMapping("/info/{id}")
    public CommonResult<RoutineMaintenance> info(@PathVariable("id") String id) {
        RoutineMaintenance routineMaintenance = routineMaintenanceService.getById(id);
        return CommonResult.success(routineMaintenance);
    }
}
